﻿#include "TestPoolAlloc.h"

void CTestPoolAlloc::Push(unsigned int val)
{
	while(val)
	{
		TestObj obj;
		obj.setValue(val);
		this->lst.push_back(val--);
		this->lstBig.push_back(obj);
	}
}

void CTestPoolAlloc::Pop()
{
	if(!this->lst.empty())
	{
		this->lst.pop_back();
		this->lstBig.pop_back();
	}
}

void CTestPoolAlloc::ViolenceTest(size_t num, int rate)
{
	rate = rate > 100 ? 100 : rate;
	rate = rate < 0 ? 0 : rate;

	int val = 0;
	size_t pos = 0;
	for(; pos < num; ++pos)
	{
		val = (rand() % 101);
		if(val > rate)
		{
			this->Push(val);
		}
		else
		{
			this->Pop();
		}
	}
}
